package com.java.imauoj.mapper;

import com.java.imauoj.moudel.Solution;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SubmitMapper {

    @Insert("insert into source_code(solution_id,source) values(#{solution_id},#{source})")
    void addSourceCode(int solution_id, String source);

    @Insert("insert into solution(problem_id,user_id,language,ip,contest_id,num,in_date) " +
            "values(#{problem_id},#{user_id},#{language},#{ip},#{contest_id},#{num},NOW())")
    @Options(useGeneratedKeys=true, keyProperty="solution_id")
    void addSolution(Solution solution);

    @Select("select * from solution where solution_id=#{solution_id}")
    Solution getResult(int solution_id);

    @Select("select * from solution ${sql}")
    List<Solution> getSolutionList(String sql,String[] list);

    @Select("select * from solution where solution_id=#{solution_id}")
    List<Solution> getSolution(int solution_id);
}
